package com.leslie.app.constant;

import org.springframework.http.HttpStatus;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public enum ErrorMap {
    NAME_HAS_BEEN_TAKEN("LESLIE_001", "USER ERROR", HttpStatus.BAD_REQUEST),
    PASSWORD_NOT_MATCH("LESLIE_002", "USER ERROR", HttpStatus.BAD_REQUEST);



    private final String code;
    private final String message;
    private final HttpStatus status;

    ErrorMap(String code, String message, HttpStatus status) {
        this.code = code;
        this.message = message;
        this.status = status;
    }

    public static ErrorMap getErrorMapEnum(String code) {
        Map<String, ErrorMap> errorMap = Arrays.stream(ErrorMap.values()).collect(Collectors.toMap(ErrorMap::getCode, errorEnum -> errorEnum));
        return errorMap.get(code);
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public HttpStatus getStatus() {
        return status;
    }
}
